package com.plian.system.controller.cqzc.bondissue;

import com.plian.Tools.base.BaseController;
import com.plian.Tools.pagedata.PageData;
import com.plian.system.annotation.Behavioral;
import com.plian.system.annotation.LogOperation;
import com.plian.system.model.ListResult;
import com.plian.system.model.ObjResult;
import com.plian.system.service.cqzc.bondissue.BondsIssueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 说明：债券发行
 * 创建时间:2020-04-27 17:27:14
 */
@RestController
@RequestMapping(value = "api/bond_issue")
public class BondsIssueController extends BaseController {

    @Autowired
    private BondsIssueService bondissueService;


    /**
     * 保存
     *
     * @param
     * @throws Exception
     */
    @PostMapping(value = "/save")
	@LogOperation("债券发行-保存")
    public ObjResult save(@RequestBody PageData pd) throws Exception {
        return bondissueService.save(pd);
    }

    /**
     * 修改
     *
     * @param
     * @throws Exception
     */
    @PostMapping(value = "/edit")
	@LogOperation("债券发行-编辑")
    public ObjResult edit(@RequestBody PageData pd) throws Exception {
        return bondissueService.edit(pd);
    }

    /**
     * 根据id查询
     *
     * @param pd
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/findbyid")
    @Behavioral
    public ObjResult detail(@RequestBody PageData pd) throws Exception {
        return bondissueService.findbyid(pd);
    }

    /**
     * 根据集合删除数据
     *
     * @param pd
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/del_ids")
	@LogOperation("债券发行-删除")
    public ObjResult delids(@RequestBody PageData pd) throws Exception {
        return bondissueService.del_ids((List<String>) pd.get("ids"));
    }

    /**
     * 查询列表
     *
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/list")
    public ListResult listpage(@RequestBody PageData pd) throws Exception {
        return bondissueService.listPage(pd);
    }

    /**
     * 查询列表
     *
     * @return
     * @throws Exception
     */
    @PostMapping(value = "/issueList")
    public ListResult issueList(@RequestBody PageData pd) throws Exception {
        return bondissueService.issueList(pd);
    }

    @PostMapping(value = "/reportList")
    public ListResult reportList(@RequestBody PageData pd) throws Exception {
        return bondissueService.reportList(pd);
    }

    @PostMapping(value = "/remainingIssuableAmount")
    @LogOperation("债券发行-查询剩余可发债额度")
    public ObjResult remainingIssuableAmount(@RequestBody PageData pd) throws Exception {
        return bondissueService.remainingIssuableAmount(pd);
    }

    @PostMapping(value = "/report")
    public ObjResult report(@RequestBody PageData pd) throws Exception {
        return bondissueService.report(pd);
    }

//	/**
//	 * 发债主体 统计表
//	 * @param pd
//	 * @return
//	 * @throws Exception
//	 */
//	@PostMapping(value = "/issueSummary")
//	public R<ReportReturnVO> issueSummary(@RequestBody PageData pd)throws Exception {
//		ReportReturnVO reportReturnVO = bondissueService.issueSummary(pd);
//		R<ReportReturnVO> results = new R<>(CommonCode.SUCCESS);
//		results.setPageData(reportReturnVO);
//		return results;
//	}

//	/** TODO DEL
//	 * 发债主体、债券品种 穿透
//	 * @param pd
//	 * @return
//	 * @throws Exception
//	 */
//	@PostMapping(value = "/applySummaryDetail")
//	public R<ReportReturnVO> applySummaryDetail(@RequestBody PageData pd)throws Exception {
//		ReportReturnVO reportReturnVO = bondissueService.applySummaryDetail(pd);
//		R<ReportReturnVO> results = new R<>(CommonCode.SUCCESS);
//		results.setPageData(reportReturnVO);
//		return results;
//	}

//	/**
//	 * 债券品种情况
//	 * @param pd
//	 * @return
//	 * @throws Exception
//	 */
//	@PostMapping(value = "/typeSummary")
//	public R<ReportReturnVO> typeSummary(@RequestBody PageData pd)throws Exception {
//		ReportReturnVO reportReturnVO = bondissueService.typeSummary(pd);
//		R<ReportReturnVO> results = new R<>(CommonCode.SUCCESS);
//		results.setPageData(reportReturnVO);
//		return results;
//	}

//	/**
//	 * 债券发行期限情况
//	 * @param pd
//	 * @return
//	 * @throws Exception
//	 */
//	@PostMapping(value = "/yearSummary")
//	public R<ReportReturnVO> yearSummary(@RequestBody PageData pd)throws Exception {
//		ReportReturnVO reportReturnVO = bondissueService.yearSummary(pd);
//		R<ReportReturnVO> results = new R<>(CommonCode.SUCCESS);
//		results.setPageData(reportReturnVO);
//		return results;
//	}

//	/**
//	 * 债券发行期限情况 穿透
//	 * @param pd
//	 * @return
//	 * @throws Exception
//	 */
//	@PostMapping(value = "/yearSummaryDetail")
//	public R<ReportReturnVO> yearSummaryDetail(@RequestBody PageData pd)throws Exception {
//		ReportReturnVO reportReturnVO = bondissueService.yearSummaryDetail(pd);
//		R<ReportReturnVO> results = new R<>(CommonCode.SUCCESS);
//		results.setPageData(reportReturnVO);
//		return results;
//	}

//	/** TODO DEL
//	 * 存续债券到期年份情况（亿元）
//	 * @param pd
//	 * @return
//	 * @throws Exception
//	 */
//	@PostMapping(value = "/expirationYearSummary")
//	public R<ReportReturnVO> expirationYearSummary(@RequestBody PageData pd)throws Exception {
//		ReportReturnVO reportReturnVO = bondissueService.expirationYearSummary(pd);
//		R<ReportReturnVO> results = new R<>(CommonCode.SUCCESS);
//		results.setPageData(reportReturnVO);
//		return results;
//	}

//	/**
//	 * 存续债券到期年份情况（亿元）
//	 * @param pd
//	 * @return
//	 * @throws Exception
//	 */
//	@PostMapping(value = "/expirationYearSummaryDetail")
//	public R<ReportReturnVO> expirationYearSummaryDetail(@RequestBody PageData pd)throws Exception {
//		ReportReturnVO reportReturnVO = bondissueService.expirationYearSummaryDetail(pd);
//		R<ReportReturnVO> results = new R<>(CommonCode.SUCCESS);
//		results.setPageData(reportReturnVO);
//		return results;
//	}

//	/**TODO DEL
//	 * 债券分析表
//	 * @param pd
//	 * @return
//	 * @throws Exception
//	 */
//	@PostMapping(value = "/bondAnalysis")
//	public R<ReportReturnVO> bondAnalysis(@RequestBody PageData pd)throws Exception {
//		ReportReturnVO reportReturnVO = bondissueService.bondAnalysis(pd);
//		R<ReportReturnVO> results = new R<>(CommonCode.SUCCESS);
//		results.setPageData(reportReturnVO);
//		return results;
//	}
}